package utils;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;

/**
 * @author 19242
 */
public class TextUtil {

    /**
     * 将传入对象复制到剪切板
     */
    public static String copyToClipboard(Object o){
        String str = String.valueOf(o);
        StringSelection stringSelection = new StringSelection(str);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, null);
        return str;
    }
}
